﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace TookKit.Mvvm.Helpers
{
    public class FileHelper
    {
        private static string extensionName = ".dll";

        public static List<Assembly> GetAssemblies(string path)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            if(directoryInfo.Exists)
            {
                var files = directoryInfo.GetFiles().Where(t => t.Extension.ToLower() == extensionName.ToLower());
                List<Assembly> result = new List<Assembly>();
                foreach(var file in files)
                {
                    result.Add(Assembly.LoadFrom(file.FullName));
                }
                return result;
            }

            return new List<Assembly>();
        }
    }
}
